<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div></div>
    <script>
        let div = document.getElementsByTagName('div')[0];
        let persons = [
            { "username": "xiaoming1", "password": "1111" },
            { "username": "xiaoming2", "password": "222" },
            { "username": "xiaoming3", "password": "3333" }
        ]
        let user = { "username": "xiaoming3", "password": "3333" }
        // let a = persons.some(function (item) {
        // return    item.username === user.username && item.password === user.password
        // })
        // if(a==true){
        //     div.innerText='登录成功'
        // }else{
        //     div.innerText='登录失败'
        // }
            let a=persons.some(item=>item.username === user.username && item.password === user.password)
            console.log(a)
            if(a){
                div.innerText='登录成功'
            }else{
                div.innerText='登录失败'
            }
    </script>
</body>

</html>